<?php
/**
 * FormExtHelper.
 *
 * @package    viajemoz
 * @subpackage helper
 * @author     Jonathan Olger Nieto Lajo <jonathan_nieto@hotmail.com>
 */

function select_doctrine_status_tag($name, $model, $selected = null, $options = array(), $attributes = array(), $errors = array())
{
  $options = array_merge(array('model' => $model), $options);
	
  $select = new sfWidgetFormDoctrineSelect($options);
  return $select->render($name, $selected, $attributes, $errors);
}

function select_doctrine_country_tag($name, $model, $selected = null, $options = array(), $attributes = array(), $errors = array())
{
  $select = new sfWidgetFormDoctrineCountrySelect($options);
  return $select->render($name, $selected, $attributes, $errors);
}

function radiobutton_formatter_frontend($widgets, $inputs)
{
  $rows = array();
  foreach ($inputs as $input)
  {
    $rows[] = $input['input'].$input['label'];
  }
  return implode('&nbsp;&nbsp;&nbsp;', $rows);
}

function simple_search_form()
{
  return new SimpleSearchForm();
}

////

function select_tag($name, $choices, $selected = null, $attributes = array(), $errors = array())
{
  $select = new sfWidgetFormSelect(array('choices' => $choices));
  return $select->render($name, $selected, $attributes, $errors);
}

function select_tag_multiple($name, $choices, $selected = null, $attributes = array(), $errors = array())
{
  $select = new sfWidgetFormSelectMany(array('choices' => $choices));
  return $select->render($name, $selected, $attributes, $errors);
}

function input_tag($name, $value = null, $attributes = array(), $errors = array())
{
  $input = new sfWidgetFormInput();
  return $input->render($name, $value, $attributes, $errors);
}

function input_tag_filter($name, $value = null, $attributes = array(), $errors = array())
{
  $value = $value == '0' ? '' : get_filter_name_from_name_url($value);
  return input_tag($name, $value, $attributes, $errors);
}


function checkbox_tag($name, $value = '1', $checked = false, $attributes = array(), $errors = array())
{
  $chkbox = new sfWidgetFormInputCheckbox();
  return $chkbox->render($name, $value, $attributes, $errors);
}

function radiobutton_tag($name, $choices, $selected = null, $attributes = array(), $options = array(), $errors = array())
{
  $radio = new sfWidgetFormSelectRadio(array('choices' => $choices) + $options);
  return $radio->render($name, $selected, $attributes, $errors);
}

function input_hidden_tag($name, $value = null, $attributes = array(), $errors = array())
{
  $input = new sfWidgetFormInputHidden();
  return $input->render($name, $value, $attributes, $errors);
}

function input_date_tag($name, $value = null, $options = array(), $attributes = array(), $errors = array())
{
  $input = new sfWidgetFormDate($options);
  return $input->render($name, $value, $attributes, $errors);
}

function input_date_tag_koech_label($name, $value = null, $options = array(), $attributes = array(), $errors = array())
{
  $input = new sfWidgetFormDateKoechLabel($options);
  return $input->render($name, $value, $attributes, $errors);
}